//microcommand define -lnnbot-get-miniplug-code
function getMiniPlugCode(name, scope = ctx.loader.config.plugins) {
  for (let [k, v] of Object.entries(scope)) {
    if (k[0] === "$") continue
    if (k[0] === "~") k = k.slice(1)
    const plugin = k.split(":")[0]
    if (plugin === "group") {
        const r = getMiniPlugCode(name, v)
        if (r != null) return r
        continue
    }
    if (plugin !== "miniplug") continue
    const label = v?.$label?.replace(/^(?:@[^/]*\/)?[^/]*\//, "") ?? ""
    if (label === name) return v.code
  }
}
signature("<search>", { authority: 3 })
action(({ session }, search) => search ? (c => c ? h.text(c) : session.i18n(".not-found"))(getMiniPlugCode(search)) : session.i18n("internal.insufficient-arguments"))
locale("zh-CN", { description: "获取指定 miniplug 的源代码", messages: { "not-found": "未找到此名称的 miniplug。" } })